<?php
include_once "common.php";
$a=[111,3,5,100=>"Hello",true];
var_dump($a);
$a=['name'=>'张三','age'=>18,'sex'=>'男'];
print_r($a);
$a=['24jsj1','name'=>'张三',0=>'24jsj2','name'=>'张三丰',];
print_r($a);

//key值只能是整数或string,其他类型需要转换
$array=array(
    1=>'a',
    '1'=>'b',//值"a"会被"b"覆盖
    1.5=>'c',
    -1=>'d',
    '01'=>'e',
    '1.5'='f',
    true=>'g',
    false=>'h',
    ''=>'i',
    null=>'j',
    'k',
    2=>'1',
);
print($array);

$a=[111,222,333,"Hello",true];
for($i=0,$len=count($a);$i<$len;++$i){
    echo $i,'. ',$a[$i],"\n";
}
echo"---------------------------\n";
$a=[111,222,333,"Hello",true];
foreach ($a as $v){
    echo $v,"\n";
}
$a=[111,'name'=>'张三',345,'age'=>18];
foreach ($a as $key=>$value) {
    echo $key,' --->',$value,"\n";
}